﻿<%@ Page Language="C#" AutoEventWireup="true" Codebehind="TestTreeEditor.aspx.cs"
    Inherits="mmq.TestTreeEditor" Theme="Grey" %>

<%@ Register Src="~/UserControls/TreeEditor.ascx" TagName="TreeEditor" TagPrefix="treeEditor" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            <treeEditor:TreeEditor ID="TreeEditor1" runat="server"></treeEditor:TreeEditor>
        </div>
        <p>
            <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1"
                DataKeyNames="CategoryID" OnItemCommand="DetailsView1_ItemCommand" BackColor="LightGoldenrodYellow"
                BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None"
                AutoGenerateRows="False" AutoGenerateDeleteButton="true" AutoGenerateEditButton="true"
                AutoGenerateInsertButton="true" OnItemCreated="DetailsView1_ItemCreated" OnItemDeleted="DetailsView1_ItemDeleted"
                OnItemDeleting="DetailsView1_ItemDeleting" OnItemInserted="DetailsView1_ItemInserted"
                OnItemInserting="DetailsView1_ItemInserting" OnItemUpdated="DetailsView1_ItemUpdated"
                OnItemUpdating="DetailsView1_ItemUpdating">
                <FooterStyle BackColor="Tan" />
                <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                <HeaderStyle BackColor="Tan" Font-Bold="True" />
                <AlternatingRowStyle BackColor="PaleGoldenrod" />
                <Fields>
                    <asp:TemplateField>
                        <EditItemTemplate>
                            <asp:LinkButton Text="Append Child" CommandName="Update" CommandArgument="AppendChild"
                                runat="server" />
                        </EditItemTemplate>
                        <InsertItemTemplate>
                        </InsertItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Category ID: ">
                        <ItemTemplate>
                            <asp:Label ID="lbl_CategoryID" Text='<%# Eval("CategoryID") %>' runat="Server" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Label ID="lbl_CategoryID" Text='<%# Eval("CategoryID") %>' runat="Server" />
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:Label ID="lbl_CategoryID" Text='<%# Eval("CategoryID") %>' runat="Server" />
                        </InsertItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="parent ID: ">
                        <ItemTemplate>
                            <asp:Label ID="lbl_parentID" Text='<%# Eval("parentID") %>' runat="Server" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Label ID="lbl_parentID" Text='<%# Eval("parentID") %>' runat="Server" />
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:Label ID="lbl_parentID" Text='<%# TreeEditor1.SelectedParentValue %>' runat="Server" />
                        </InsertItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Title">
                        <ItemTemplate>
                            <asp:Label ID="lbl_title" Text='<%# Eval("title") %>' runat="Server" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txt_Title" runat="server" Text='<%# Bind("title") %>' Columns="50" />
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:TextBox ID="txt_Title" runat="server" Text='<%# Bind("title") %>' Columns="50" />
                        </InsertItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Description">
                        <ItemTemplate>
                            <asp:Label ID="lbl_description" Text='<%# Eval("description") %>' runat="Server" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txt_description" runat="server" Text='<%# Bind("description") %>'
                                Columns="50" />
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:TextBox ID="txt_description" runat="server" Text='<%# Bind("description") %>'
                                Columns="50" />
                        </InsertItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="中文目录名">
                        <ItemTemplate>
                            <asp:Label ID="lbl_cntitle" Text='<%# Eval("cn_title") %>' runat="Server" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txt_cnTitle" runat="server" Text='<%# Bind("cn_title") %>' Columns="50" />
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:TextBox ID="txt_cnTitle" runat="server" Text='<%# Bind("cn_title") %>' Columns="50" />
                        </InsertItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="中文说明">
                        <ItemTemplate>
                            <asp:Label ID="lbl_cndescription" Text='<%# Eval("cn_description") %>' runat="Server" />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txt_cndescription" runat="server" Text='<%# Bind("cn_description") %>'
                                Columns="50" />
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:TextBox ID="txt_cndescription" runat="server" Text='<%# Bind("cn_description") %>'
                                Columns="50" />
                        </InsertItemTemplate>
                    </asp:TemplateField>
                </Fields>
            </asp:DetailsView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AC_DBConnectionString %>"
                SelectCommand="SELECT * FROM [AC_Category] WHERE ([CategoryID] = @CategoryID)"
                DeleteCommand="DELETE FROM [AC_Category] WHERE [CategoryID] = @CategoryID" InsertCommand="INSERT INTO [AC_Category] ([parentID], [title], [description], [cn_title], [cn_description]) VALUES (@parentID, @title, @description, @cn_title, @cn_description)"
                UpdateCommand="UPDATE [AC_Category] SET [title] = @title, [description] = @description,[cn_title] = @cn_title, [cn_description] = @cn_description WHERE [CategoryID] = @CategoryID">
                <SelectParameters>
                    <asp:ControlParameter ControlID="TreeEditor1" Name="CategoryID" PropertyName="SelectedValue"
                        Type="Int16" />
                </SelectParameters>
                <DeleteParameters>
                    <asp:Parameter Name="CategoryID" Type="Int16" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="parentID" Type="Int16" />
                    <asp:Parameter Name="title" Type="String" />
                    <asp:Parameter Name="description" Type="String" />
                    <asp:Parameter Name="CategoryID" Type="Int16" />
                    <asp:Parameter Name="cn_title" Type="String" />
                    <asp:Parameter Name="cn_description" Type="String" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:ControlParameter ControlID="TreeEditor1" PropertyName="SelectedParentValue"
                        Name="parentID" Type="Int16" />
                    <asp:Parameter Name="title" Type="String" />
                    <asp:Parameter Name="cn_title" Type="String" />
                    <asp:Parameter Name="cn_description" Type="String" />
                    <asp:Parameter Name="description" Type="String" />
                </InsertParameters>
            </asp:SqlDataSource>
        </p>
        <p>
            <asp:Label ID="lbl_msg" runat="server" ForeColor="red" Font-Bold="true"></asp:Label>
        </p>
    </form>
</body>
</html>
